package gogogo.liwushuo.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import butterknife.ButterKnife;
import butterknife.InjectView;
import gogogo.liwushuo.R;
import gogogo.liwushuo.activity.SignInActivity;

public class ProfileFragment extends Fragment {
    @InjectView(R.id.imageView2)
    ImageView imageView2;
    @InjectView(R.id.imageView)
    ImageView imageView;
    @InjectView(R.id.boy)
    ImageView boy;
    @InjectView(R.id.rb_profile1)
    RadioButton rbProfile1;
    @InjectView(R.id.rb_profile2)
    RadioButton rbProfile2;
    @InjectView(R.id.rg_profile)
    RadioGroup rgProfile;
    @InjectView(R.id.tv_liwu_gonglue)
    TextView tvLiwuGonglue;

    public ProfileFragment() {

    }

    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    private void setListener() {
        imageView2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getActivity(), SignInActivity.class));
            }
        });
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getActivity(), SignInActivity.class));
            }
        });
        boy.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getActivity(), SignInActivity.class));
            }
        });
        rgProfile.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getActivity(), SignInActivity.class));
            }
        });
        tvLiwuGonglue.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getActivity(), SignInActivity.class));
            }
        });

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_profile, container, false);
        ButterKnife.inject(this, view);
        setListener();
        return view;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        rgProfile = (RadioGroup) view.findViewById(R.id.rg_profile);
        tvLiwuGonglue = (TextView) view.findViewById(R.id.tv_liwu_gonglue);
        rgProfile.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                switch (checkedId) {
                    case R.id.rb_profile1:
                        tvLiwuGonglue.setText("喜欢的礼物摆在这里哦");
                        break;
                    case R.id.rb_profile2:
                        tvLiwuGonglue.setText("喜欢的攻略放在这里哦");
                        break;
                }
            }
        });
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.reset(this);
    }
}
